* Chapter 5 - mapping the gap

set scheme plotplain


use Elites five countries all GGIs.dta, clear 
drop confAU confEU confASEAN confNAFTA confMERCOSUR confSCO confNATO confUNFCCC confUNSC confG20 confICANN confFSC confKP confFIFA

save Elites five countries six GGIs CH5.dta, replace

save "Elites five countries six GGIs CH5.dta"

* Figure 5.1. - gap by IO
**************************

use wvs7.dta, clear
mean confios  [pweight=S018]
mean confICC  [pweight=S018]
mean confIMF  [pweight=S018]
mean confUN  [pweight=S018]
mean confWB  [pweight=S018]
mean confWHO  [pweight=S018]
mean confWTO [pweight=S018]
mean confgov  [pweight=S018]
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov  [pweight=S018]
gen group="Citizens"
save fig5.1_citizens.dta, replace



use "Elites five countries six GGIs CH5.dta", clear
mean confios 
mean confICC 
mean confIMF 
mean confUN 
mean confWB 
mean confWHO 
mean confWTO
mean confgov 
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov
gen group="Elites"
save fig5.1_elites.dta


use fig5.1_citizens.dta, clear
append using fig5.1_elites.dta
*add diff manually 0.350792	0.4477	0.29584	0.43858	0.35858	0.49822	0.20404	0.28959
replace group="Elite-citizen gap" in 3 
label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.1.dta, replace


use fig5.1.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr



* Figure 5.2 Elite estimation of public confidence in IOs
**********************************************************	

use "Elites five countries six GGIs CH5.dta", clear


sum pubconfgov pubconfUN pubconfIMF pubconfICC pubconfWB pubconfWHO pubconfWTO

drop confgov confUN confIMF confICC confWB confWHO confWTO confios
gen confgov=pubconfgov
gen confUN=pubconfUN
gen confIMF= pubconfIMF
gen confICC=pubconfICC
gen confWB=pubconfWB
gen confWHO=pubconfWHO
gen confWTO=pubconfWTO
gen confios= (confUN+confIMF+confICC+confWB+confWB+confWHO+confWTO)/6

collapse confios confUN confIMF confICC confWB confWHO confWTO confgov
gen group="Elite estimation"
save fig5.2_elitesperceived.dta, replace



use wvs7.dta, clear

mean confios [pweight=S018]
mean confICC [pweight=S018]
mean confIMF [pweight=S018]
mean confUN [pweight=S018]
mean confWB [pweight=S018]
mean confWHO [pweight=S018]
mean confWTO [pweight=S018]
mean confgov [pweight=S018]
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov [pweight=S018]
gen group="Citizens"
save fig5.2_citizens.dta




use "Elites five countries six GGIs CH5.dta", clear

mean confios 
mean confICC 
mean confIMF 
mean confUN 
mean confWB 
mean confWHO 
mean confWTO
mean confgov 
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov
gen group="Elites"
save fig5.2_elites.dta



use fig5.2_citizens.dta, clear
append using fig5.2_elites.dta
append using fig5.2_elitesperceived.dta

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.2.dta, replace


set scheme plotplain

use fig5.2.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confeliteestimation
rename conf3 confelites 

#delimit ;
graph bar  confelites confeliteestimation confcitizens  , 
 over(ionum, sort(confelites) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Elite estimation" 3 "Citizens"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr






* Figure 5.3 gap by IO by country
*********************************

* gov
use wvs7.dta
collapse confgov [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensgov.dta, replace

collapse confgov, by(country)
gen group="Elites"
save fig5.3_elitesgov.dta, replace
append using fig5.3_citizensgov.dta
gen countrystr=""
ed
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually 0.62010863 0.704616 -0.5447724 0.2372253 0.4567727
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesgov.dta", replace

encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confgov1 confcitizens
rename confgov2 confgap
rename confgov3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence) 
title(Government)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr


*ICC

use wvs7.dta
collapse confICC [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensICC.dta, replace

use "Elites five countries six GGIs CH5.dta", clear
collapse confICC, by(country)
gen group="Elites"
save fig5.3_elitesICC.dta, replace

use fig5.3_citizensICC.dta, clear
append using fig5.3_elitesICC.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually  .80247 .76253 .03463 .28881 .35069
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesICC.dta", replace

use fig5.3_citizenselitesICC.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confICC1 confcitizens
rename confICC2 confgap
rename confICC3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence) 
title(ICC)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr


* IMF
set scheme plotplain

clear
use wvs7.dta, clear
collapse confIMF [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensIMF.dta, replace


use "Elites five countries six GGIs CH5.dta", clear
collapse confIMF, by(country)
gen group="Elites"
save fig5.3_elitesIMF.dta, replace

use fig5.3_citizensIMF.dta, clear
append using fig5.3_elitesIMF.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually confIMF .54069 .48266 -.30862 .387449 .4928
ed
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesIMF.dta", replace


use fig5.3_citizenselitesIMF.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confIMF1 confcitizens
rename confIMF2 confgap
rename confIMF3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(IMF)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr


* UN
set scheme plotplain
clear
use wvs7.dta, clear
collapse confUN [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensUN.dta, replace


use "Elites five countries six GGIs CH5.dta", clear
collapse confUN, by(country)
gen group="Elites"
save fig5.3_elitesUN.dta, replace

use fig5.3_citizensUN.dta, clear
append using fig5.3_elitesUN.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually confUN .61731 .41011 .09469 .936795 .3505
edit
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesUN.dta", replace


use fig5.3_citizenselitesUN.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confUN1 confcitizens
rename confUN2 confgap
rename confUN3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(UN)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

* WB
set scheme plotplain
clear
use wvs7.dta, clear
collapse confWB[pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensWB.dta, replace


use "Elites five countries six GGIs CH5.dta", clear 
collapse confWB, by(country)
gen group="Elites"
save fig5.3_elitesWB.dta, replace

use fig5.3_citizensWB.dta, clear
append using fig5.3_elitesWB.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually confWB .55761 .54969 -.24544 .479124 .58291
edit
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesWB.dta", replace


use fig5.3_citizenselitesWB.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confWB1 confcitizens
rename confWB2 confgap
rename confWB3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(World Bank)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr


* WHO
set scheme plotplain
clear
use wvs7.dta, clear
collapse confWHO [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensWHO.dta, replace


use "Elites five countries six GGIs CH5.dta", clear
collapse confWHO, by(country)
gen group="Elites"
save fig5.3_elitesWHO.dta, replace

use fig5.3_citizensWHO.dta, clear
append using fig5.3_elitesWHO.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
* add differences manually: 0,92258 0,32513 0,11736 0,73302 0,48028  
edit
replace group="Elite-citizen gap" in 11/15
save "fig5.3_citizenselitesWHO.dta", replace


use fig5.3_citizenselitesWHO.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confWHO1 confcitizens
rename confWHO2 confgap
rename confWHO3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(WHO)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

* WTO
set scheme plotplain
clear
use wvs7.dta, clear
collapse confWTO [pweight=S018], by(country)
gen group="Citizens"
save fig5.3_citizensWTO.dta, replace


use "Elites five countries six GGIs CH5.dta", clear
collapse confWTO, by(country)
gen group="Elites"
save fig5.3_elitesWTO.dta, replace

use fig5.3_citizensWTO.dta, clear
append using fig5.3_elitesWTO.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
edit

replace group="Elite-citizen gap" in 11/15
* add differences manually confWTO .49751 .348 -.3731 .27188 .35062

save "fig5.3_citizenselitesWTO.dta", replace


use fig5.3_citizenselitesWTO.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confWTO1 confcitizens
rename confWTO2 confgap
rename confWTO3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(WTO)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr







* Figure 5.4 - gap by country (allIOs)
**************************************

use wvs7.dta, clear, clear

mean confios [pweight=S018] if country==76
mean confios [pweight=S018] if country==276

collapse confios [pweight=S018], by(country)
gen group="Citizens"
save fig5.4_citizens.dta, replace



use "Elites five countries six GGIs CH5.dta", clear

mean confios  if country==76
mean confios  if country==276
collapse confios, by(country)
gen group="Elites"
save fig5.4_elites.dta

use fig5.4_citizens.dta, clear
append using fig5.4_elites.dta
gen countrystr=""
replace countrystr="Brazil" if country==76
replace countrystr="Philippines" if country==608
replace countrystr="US" if country==840
replace countrystr="Germany" if country==276
replace countrystr="Russia" if country==643
local new = _N + 8
set obs `new'
replace countrystr="All" in 11/13
replace group="Citizens" in 11
replace group="Elites" in 12
replace group="Elite-citizen gap" in 13
replace confios=1.43 in 11
replace confios=1.78 in 12
replace confios=0.35 in 13
* add differences manually .633632 .476256 -.121988 .506457 .431615
save "fig5.4_citizenselites.dta", replace


use fig5.4_citizenselites.dta, clear
encode countrystr, gen(countrynum)
encode group, gen(groupnum)
sort group country 
ed
drop country countrystr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confios1 confcitizens
rename confios2 confgap
rename confios3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr





* Figure 5.5 - Elite-citizen gap in confidence per country by IO
*****************************************************************	


set scheme plotplain

use wvs7.dta, clear, clear

mean confgov if country==276
mean confgov [pweight=S018] if country==276

collapse  confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(country)
gen group="Citizens"
save fig5.5_citizens.dta, replace



use "Elites five countries six GGIs CH5.dta", clear
collapse  confgov confios confUN confIMF confICC confWB confWHO confWTO, by(country)
gen group="Elites"
save fig5.5_elites.dta, replace


use fig5.5_citizens.dta
append using fig5.5_elites.dta

* add Elite-citizen gap per country and institutions manually
0.620105	0.633632	0.61731	0.54069	0.80247	0.55761	0.92258	0.49751
0.76209	0.476256	0.41011	0.48266	0.76253	0.54969	0.32513	0.348
-0.54477	-0.121988	0.09469	-0.30862	0.03463	-0.24544	0.11736	-0.3731
0.24392	0.506457	0.936795	0.387449	0.28881	0.479124	0.73302	0.27188
0.45678	0.431615	0.3505	0.4928	0.35069	0.58291	0.48028	0.35062

* 76= BR
* 276= DE
* 608= PH
* 643= RU
* 840= US

replace group="Elite-citizen gap" in 11/15
save fig5.5_citizenselites.dta, replace

* Brazil
use  fig5.5_citizenselites.dta, clear
keep if country==76
save fig5.5_citizenselitesBR.dta, replace

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.5BR.dta, replace

use fig5.5BR.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Brazil)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.5brazil.gph



* Germany

set scheme plotplain

use  fig5.5_citizenselites.dta, clear
keep if country==276
save fig5.5_citizenselitesDE.dta, replace

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.5DE.dta, replace

use fig5.5DE.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Germany)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.5Germany.gph, replace



* Philippines
set scheme plotplain


use  fig5.5_citizenselites.dta, clear
keep if country==608
save fig5.5_citizenselitesPH.dta, replace

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.5PH.dta, replace

use fig5.5PH.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Philippines)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save fig5.5Philippines.gph


* Russia

set scheme plotplain


use  fig5.5_citizenselites.dta , clear
keep if country==643
save fig5.5_citizenselitesRU.dta, replace

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.5RU.dta, replace

use fig5.5RU.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Russia)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save fig5.5Russia.gph



* US

set scheme plotplain

use fig5.5_citizenselites.dta, clear
keep if country==840
save fig5.5_citizenselitesUS.dta, replace

label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.5US.dta, replace

use fig5.5US.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(US)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.5US.gph 


* Figure 5.6 elite estimation by country
****************************************

use "wvs7.dta"

collapse confios [pweight=S018], by(country)
gen group="Citizens"
save fig5.6_citizensios.dta, replace



use "Elites five countries six GGIs CH5.dta"

collapse confios, by(country)
gen group="Elites"
save fig5.6_elitesios.dta, replace



use "fig5.2_elitesperceived_sigtest.dta"
collapse confios, by(country)
gen group="Elite estimation"
save fig5.6_estimationios.dta, replace


use fig5.6_citizensios.dta, clear
append using fig5.6_elitesios.dta 
append using fig5.6_estimationios.dta
save fig5.6.dta, replace


use fig5.6.dta, clear

set scheme plotplain

encode group, gen(groupnum)
drop group
reshape wide conf, i(country) j(groupnum)
rename confios1 confcitizens
rename confios2 confestimation
rename confios3 confelites

#delimit ;
graph bar confelites confestimation confcitizens, 
 over(country, sort(confelites) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Elite estimation" 3 "Citizens"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr




* Figure 5.7 - gap by elite sector (allIOs)
*******************************************

use wvs7.dta, clear, clear


collapse confios [pweight=S018]
gen group="Citizens"
save fig5.7_citizens.dta, replace



use "Elites five countries six GGIs CH5.dta", clear

tab elitecat
collapse confios, by(elitecat)
gen group="Elites"
save fig5.7_elites.dta, replace

use fig5.7_citizens.dta, clear
append using fig5.7_elites.dta
gen elitestr=""
replace elitestr="Partisan-political" if elitecat==1
replace elitestr="Bureaucratic" if elitecat==2
replace elitestr="Civil society" if elitecat==3
replace elitestr="Media" if elitecat==4
replace elitestr="Business" if elitecat==5
replace elitestr="Research" if elitecat==6
* add citizen value manually for each elite sector (below)
* add differences manually confios .260207 .515135 .119987 .266093 .404024 .423072
* add 'All' confcitizens	confgap	confelites
* 1.429309	.350691	1.78
replace group="Elite-citizen gap" in 8/13
save "fig5.7_citizenselites.dta", replace

set scheme plotplain

use fig5.7_citizenselites.dta, clear
encode elitestr, gen(countrynum)
encode group, gen(groupnum)
sort group elitecat 
ed
drop elitecat elitestr group 
reshape wide conf, i(countrynum) j(groupnum)
rename confios1 confcitizens
rename confios2 confgap
rename confios3 confelites
#delimit ;
graph bar confelites confcitizens confgap, 
 over(countrynum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr








* Figure 5.8. Elite-citizen gap in confidence by elite sector and IO
********************************************************************	


use wvs7.dta, clear, clear

collapse confios confUN confIMF confICC confWB confWHO confWTO confgov [pweight=S018]
gen group="Citizens"
save fig5.8_citizens.dta


use "Elites five countries six GGIs CH5.dta", clear
collapse  confgov confios confUN confIMF confICC confWB confWHO confWTO, by(elitecat)
gen group="Elites"
save fig5.8_elites.dta, replace


use  fig5.8_citizens.dta, clear
append using  fig5.8_elites.dta
save fig5.8_citizenselites.dta

* add Elite-citizen gap per sector and institution manually
0.260207	0.38658	0.12728	0.29732	0.22634	0.54026	0.11085	0.4179
0.515135	0.52478	0.5265	0.55641	0.54705	0.59392	0.37875	0.54604
0.119987	0.4	-0.0737	0.60219	-0.0269	0.41762	-0.22829	-0.05283
0.266093	0.23237	0.17898	0.3788	0.24298	0.39361	0.10715	0.08665
0.404024	0.59275	0.5793	0.09404	0.60227	0.2656	0.50879	0.13403
0.423072	0.49876	0.34713	0.57552	0.48307	0.57687	0.27804	0.16668

save "fig5.8_citizenselites.dta", replace


* Bureaucratic

set scheme plotplain

use  fig5.8_citizenselites.dta
keep if elitecat==2 | elitecat==.
save fig5.8_citizenselitesbureaucratic.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_bureaucratic.dta, replace


use fig5.8_bureaucratic.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Bureaucratic)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_bureaucratic.gph, replace

save fig5.8_bureaucratic.dta, replace




* Business

use  fig5.8_citizenselites.dta, clear
keep if elitecat==5 | elitecat==.
save fig5.8_citizenselitesbusiness.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_business.dta, replace


use fig5.8_business.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Business)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_business.gph, replace

save fig5.8_business.dta, replace




* Civil society

use fig5.8_citizenselites.dta, clear
keep if elitecat==3 | elitecat==.
save fig5.8_citizenselitescivil.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_civil.dta, replace


use fig5.8_civil.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Civil society)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_civil.gph, replace

save fig5.8_civil.dta, replace



* Media

use  fig5.8_citizenselites.dta, clear
keep if elitecat==4 | elitecat==.
save fig5.8_citizenselitesmedia.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_media.dta, replace


use fig5.8_media.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Media)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_media.gph, replace

save fig5.8_media.dta, replace


* Partisan-political

use  fig5.8_citizenselites.dta, clear
keep if elitecat==1 | elitecat==.
save fig5.8_citizenselitesparty.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_party.dta, replace


use fig5.8_party.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Partisan-political)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_party.gph, replace

save fig5.8_party.dta, replace


* Research
use  fig5.8_citizenselites.dta, clear
keep if elitecat==6 | elitecat==.
save fig5.8_citizenselitesresearch.dta


label var confICC "ICC"
label var confIMF "IMF"
label var confios "IOs"
label var confUN "UN"
label var confWHO "WHO"
label var confWTO "WTO"
label var confWB "WB"
label var confgov "gov"
ed
save fig5.8_research.dta, replace


use fig5.8_research.dta, clear
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
encode group, gen(groupnum)
drop io id group elitecat
reshape wide conf, i(ionum) j(groupnum)
rename conf1 confcitizens
rename conf2 confgap
rename conf3 confelites

#delimit ;
graph bar confelites confcitizens confgap, 
 over(ionum, sort(confgap) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Citizens" 3 "Elite-citizen gap"))
 ytitle(Average confidence)
 title(Research)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr

graph save "Graph" fig5.8_research.gph, replace 

save fig5.8_research.dta, replace



* Figure 5.9 elite estimation by country
****************************************

use "wvs7.dta"

collapse confios [pweight=S018]
gen group="Citizens"
save fig5.9_citizensios.dta, replace



use "Elites five countries six GGIs CH5.dta"

collapse confios, by(elitecat)
gen group="Elites"
save fig5.9_elitesios.dta, replace



use "fig5.2_elitesperceived_sigtest.dta"
collapse confios, by(elitecat)
gen group="Elite estimation"
save fig5.9_estimationios.dta, replace


use fig5.9_citizensios.dta, clear
append using fig5.9_elitesios.dta 
append using fig5.9_estimationios.dta
save fig5.9.dta, replace


use fig5.9.dta, clear

set scheme plotplain

encode group, gen(groupnum)
drop group
reshape wide conf, i(elitecat) j(groupnum)
rename confios1 confcitizens
rename confios2 confestimation
rename confios3 confelites

#delimit ;
graph bar confelites confestimation confcitizens, 
 over(elitecat, sort(confelites) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
labsize(small) labcolor(black) angle(horizontal) ///
glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall)order(1 "Elites" 2 "Elite estimation" 3 "Citizens"))
 ytitle(Average confidence)
bar(1, fcolor(gs14) fintensity(100)) 
bar(2, fcolor(gs8) fintensity(100)) 
bar(3, fcolor(gs2) fintensity(100)) 
blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr








*************
* Significance tests differences between citizens and elites as described in figure notes
*************


use "citizens_BR DE RU US PHI - variables dropped for dyads recoded.dta"

gen group="Citizens"

save citizens_ttest.dta, replace


use "elites_BR DE RU US PHI - variables dropped for dyads recoded.dta"

gen group="Elites"

save elites_ttest.dta, replace

use "citizens_ttest.dta"
append using "elites_ttest.dta"

gen groupnum=1 if group=="Citizens"
replace groupnum=2 if group=="Elites"
tab groupnum


* Generate weight that includes elites (factor 1)
gen extS018 = S018
replace extS018=1 if groupnum==2

save elites_citizens_ttest.dta


* figure 5.1
use "elites_citizens_ttest.dta"

svyset [pw=extS018], strata(country)
svy: mean confios, over(groupnum)
svy: mean confios, over(groupnum) coeflegend
test  _b[c.confios@1bn.groupnum] =  _b[c.confios@2.groupnum]

svy: mean confUN, over(groupnum) coeflegend
test  _b[c.confUN@1bn.groupnum] =  _b[c.confUN@2.groupnum] 

svy: mean confWHO, over(groupnum) coeflegend
test  _b[c.confWHO@1bn.groupnum] =  _b[c.confWHO@2.groupnum]

svy: mean confICC, over(groupnum) coeflegend
test  _b[c.confICC@1bn.groupnum] =  _b[c.confICC@2.groupnum]

svy: mean confWB, over(groupnum) coeflegend
test  _b[c.confWB@1bn.groupnum] =  _b[c.confWB@2.groupnum]

svy: mean confIMF, over(groupnum) coeflegend
test  _b[c.confIMF@1bn.groupnum] =  _b[c.confIMF@2.groupnum]

svy: mean confgov, over(groupnum) coeflegend
test  _b[c.confgov@1bn.groupnum] =  _b[c.confgov@2.groupnum]

svy: mean confWTO, over(groupnum) coeflegend
test  _b[c.confWTO@1bn.groupnum] =  _b[c.confWTO@2.groupnum]




* figure 5.2

use "Elites five countries all GGIs.dta" 

sum pubconfgov pubconfUN pubconfIMF pubconfICC pubconfWB pubconfWHO pubconfWTO

drop confgov confUN confIMF confICC confWB confWHO confWTO
gen confgov=pubconfgov
gen confUN=pubconfUN
gen confIMF= pubconfIMF
gen confICC=pubconfICC
gen confWB=pubconfWB
gen confWHO=pubconfWHO
gen confWTO=pubconfWTO
drop confios
gen confios= (confUN+confIMF+confICC+confWB+confWB+confWHO+confWTO)/6

gen group="Elite estimation"
gen groupnum=3
save fig5.2_elitesperceived_sigtest.dta, replace


use "citizens_BR DE RU US PHI - variables dropped for dyads recoded.dta"

gen group="Citizens"
gen groupnum=1
save fig5.2_citizens_sigtest.dta, replace


use "fig5.2_elitesperceived_sigtest.dta"
append using "fig5.2_citizens_sigtest.dta"

tab group
tab groupnum

* Generate weight that includes elites (factor 1)
gen extS018 = S018
replace extS018=1 if groupnum==3

save elitesperceived_citizens_test.dta

use "elitesperceived_citizens_test.dta"


svyset [pw=extS018] , strata(country)

svy: mean confWHO, over(groupnum) coeflegend
test  _b[c.confWHO@3.groupnum]= _b[c.confWHO@1bn.groupnum]

svy: mean confios, over(groupnum) coeflegend
test  _b[c.confios@1bn.groupnum] = _b[c.confios@3.groupnum]

svy: mean confUN, over(groupnum) coeflegend
test  _b[c.confUN@3.groupnum]= _b[c.confUN@1bn.groupnum]

svy: mean confICC, over(groupnum) coeflegend
test _b[c.confICC@3.groupnum]=_b[c.confICC@1bn.groupnum]

svy: mean confWB, over(groupnum) coeflegend
test _b[c.confWB@3.groupnum]= _b[c.confWB@1bn.groupnum]

svy: mean confgov, over(groupnum) coeflegend
test _b[c.confgov@3.groupnum] = _b[c.confgov@1bn.groupnum]

svy: mean confWTO, over(groupnum) coeflegend
test  _b[c.confWTO@3.groupnum]=_b[c.confWTO@1bn.groupnum]

svy: mean confIMF, over(groupnum) coeflegend
test  _b[c.confIMF@3.groupnum]=_b[c.confIMF@1bn.groupnum]




* figure 5.5 and figure 5.7
use "elites_citizens_ttest.dta"

* 76= BR
* 276= DE
* 608= PH
* 643= RU
* 840= US

svyset [pw=extS018] , strata(country)

svy: mean confICC, over(groupnum country) coeflegend
test  _b[c.confICC@1bn.groupnum#608.country] =  _b[c.confICC@2.groupnum#608.country]
test  _b[c.confICC@1bn.groupnum#643.country] =  _b[c.confICC@2.groupnum#643.country]
test  _b[c.confICC@1bn.groupnum#840.country] =  _b[c.confICC@2.groupnum#840.country]


svy: mean confIMF, over(groupnum country) coeflegend
test  _b[c.confIMF@1bn.groupnum#608.country] =  _b[c.confIMF@2.groupnum#608.country]
test  _b[c.confIMF@1bn.groupnum#643.country] =  _b[c.confIMF@2.groupnum#643.country]


svy: mean confUN, over(groupnum country) coeflegend
test  _b[c.confUN@1bn.groupnum#608.country] =  _b[c.confUN@2.groupnum#608.country]
test  _b[c.confUN@1bn.groupnum#840.country] =  _b[c.confUN@2.groupnum#840.country]


svy: mean confWB, over(groupnum country) coeflegend
test _b[c.confWB@1bn.groupnum#608.country] = _b[c.confWB@2.groupnum#608.country]


svy: mean confWHO, over(groupnum country) coeflegend
test _b[c.confWHO@1bn.groupnum#608.country] = _b[c.confWHO@2.groupnum#608.country]
test _b[c.confWHO@1bn.groupnum#276.country] = _b[c.confWHO@2.groupnum#276.country]


svy: mean confWTO, over(groupnum country) coeflegend
test  _b[c.confWTO@1bn.groupnum#608.country] =  _b[c.confWTO@2.groupnum#608.country]
test  _b[c.confWTO@1bn.groupnum#643.country] =  _b[c.confWTO@2.groupnum#643.country]
test  _b[c.confWTO@1bn.groupnum#276.country] =  _b[c.confWTO@2.groupnum#276.country]


svy: mean confgov, over(groupnum country) coeflegend
test  _b[c.confgov@1bn.groupnum#608.country] =  _b[c.confgov@2.groupnum#608.country]
test  _b[c.confgov@1bn.groupnum#643.country] =  _b[c.confgov@2.groupnum#643.country]
test  _b[c.confgov@1bn.groupnum#840.country] =  _b[c.confgov@2.groupnum#840.country]



* figure 5.6
use "elites_citizens_ttest.dta"

svyset [pw=extS018] , strata(country)

svy: mean confios, over(groupnum country) coeflegend
test  _b[c.confios@1bn.groupnum#608.country] =  _b[c.confios@2.groupnum#608.country]

svy: mean confios, over(groupnum) coeflegend
test  _b[c.confios@1bn.groupnum] =  _b[c.confios@2.groupnum]




* figure 5.8
use "elites_citizens_ttest.dta"

replace elitecat=99 if groupnum==1

svyset [pw=extS018] , strata(country)

svy: mean confios, over(groupnum elitecat) coeflegend
test _b[c.confios@2.groupnum#3.elitecat] =  _b[c.confios@1bn.groupnum#99.elitecat]
test _b[c.confios@2.groupnum#1bn.elitecat] =  _b[c.confios@1bn.groupnum#99.elitecat]
test _b[c.confios@2.groupnum#4.elitecat]=  _b[c.confios@1bn.groupnum#99.elitecat]
test _b[c.confios@2.groupnum#5.elitecat]=  _b[c.confios@1bn.groupnum#99.elitecat]



* figure 5.9

use "elites_citizens_ttest.dta"

replace elitecat=99 if groupnum==1

svyset [pw=extS018] , strata(country)

svy: mean confICC, over(groupnum elitecat) coeflegend
test _b[c.confICC@2.groupnum#5.elitecat]= _b[c.confICC@1bn.groupnum#99.elitecat]
test  _b[c.confICC@2.groupnum#1bn.elitecat]= _b[c.confICC@1bn.groupnum#99.elitecat]
test _b[c.confICC@2.groupnum#4.elitecat]=  _b[c.confICC@1bn.groupnum#99.elitecat]
test _b[c.confICC@2.groupnum#2.elitecat]=  _b[c.confICC@1bn.groupnum#99.elitecat]


svy: mean confIMF, over(groupnum elitecat) coeflegend
test _b[c.confIMF@2.groupnum#3.elitecat]= _b[c.confIMF@1bn.groupnum#99.elitecat]
test _b[c.confIMF@2.groupnum#1bn.elitecat]= _b[c.confIMF@1bn.groupnum#99.elitecat]
test  _b[c.confIMF@2.groupnum#4.elitecat]= _b[c.confIMF@1bn.groupnum#99.elitecat]
test _b[c.confIMF@2.groupnum#6.elitecat]= _b[c.confIMF@1bn.groupnum#99.elitecat]


svy: mean confUN, over(groupnum elitecat) coeflegend
test  _b[c.confUN@2.groupnum#4.elitecat]= _b[c.confUN@1bn.groupnum#99.elitecat]
test  _b[c.confUN@2.groupnum#1bn.elitecat]= _b[c.confUN@1bn.groupnum#99.elitecat]


svy: mean confWB, over(groupnum elitecat) coeflegend
test _b[c.confWB@2.groupnum#3.elitecat]=  _b[c.confWB@1bn.groupnum#99.elitecat]
test _b[c.confWB@2.groupnum#1bn.elitecat]=  _b[c.confWB@1bn.groupnum#99.elitecat]
test _b[c.confWB@2.groupnum#4.elitecat]=  _b[c.confWB@1bn.groupnum#99.elitecat]
test _b[c.confWB@2.groupnum#6.elitecat]=  _b[c.confWB@1bn.groupnum#99.elitecat]


svy: mean confWHO, over(groupnum elitecat) coeflegen
test _b[c.confWHO@2.groupnum#5.elitecat]= _b[c.confWHO@1bn.groupnum#99.elitecat]
test _b[c.confWHO@2.groupnum#4.elitecat]= _b[c.confWHO@1bn.groupnum#99.elitecat]
test _b[c.confWHO@2.groupnum#3.elitecat]= _b[c.confWHO@1bn.groupnum#99.elitecat]


svy: mean confWTO, over(groupnum elitecat) coeflegen
test _b[c.confWTO@2.groupnum#3.elitecat]= _b[c.confWTO@1bn.groupnum#99.elitecat]
test _b[c.confWTO@2.groupnum#4.elitecat]= _b[c.confWTO@1bn.groupnum#99.elitecat]
test  _b[c.confWTO@2.groupnum#1bn.elitecat]= _b[c.confWTO@1bn.groupnum#99.elitecat]
test _b[c.confWTO@2.groupnum#6.elitecat]=  _b[c.confWTO@1bn.groupnum#99.elitecat]
test _b[c.confWTO@2.groupnum#2.elitecat]=  _b[c.confWTO@1bn.groupnum#99.elitecat]
test  _b[c.confWTO@2.groupnum#5.elitecat]=  _b[c.confWTO@1bn.groupnum#99.elitecat]




* Figure 5.6 

use "Elites five countries all GGIs.dta"

sum pubconfgov pubconfUN pubconfIMF pubconfICC pubconfWB pubconfWHO pubconfWTO

drop confgov confUN confIMF confICC confWB confWHO confWTO
gen confgov=pubconfgov
gen confUN=pubconfUN
gen confIMF= pubconfIMF
gen confICC=pubconfICC
gen confWB=pubconfWB
gen confWHO=pubconfWHO
gen confWTO=pubconfWTO
drop confios
gen confios= (confUN+confIMF+confICC+confWB+confWB+confWHO+confWTO)/6

gen group="Elite estimation"
gen groupnum=3
save fig5.6_elitesperceived_sigtest.dta, replace


use "citizens_BR DE RU US PHI - variables dropped for dyads recoded.dta"

gen group="Citizens"
gen groupnum=1
save fig5.6_citizens_sigtest.dta, replace


use "fig5.6_elitesperceived_sigtest.dta"
append using "fig5.6_citizens_sigtest.dta"

tab group
tab groupnum

* Generate weight that includes elites (factor 1)
gen extS018 = S018
replace extS018=1 if groupnum==3

save elitesperceived_citizens_test5.6.dta

use "elitesperceived_citizens_test5.6.dta"

* 76= BR
* 276= DE
* 608= PH
* 643= RU
* 840= US

svyset [pw=extS018] , strata(country)

svy: mean confios, over(groupnum country) coeflegend
test  _b[c.confios@1bn.groupnum#76.country] =  _b[c.confios@3.groupnum#76.country]
test  _b[c.confios@1bn.groupnum#276.country] =  _b[c.confios@3.groupnum#276.country]
test  _b[c.confios@1bn.groupnum#608.country] =  _b[c.confios@3.groupnum#608.country]
test  _b[c.confios@1bn.groupnum#643.country] =  _b[c.confios@3.groupnum#643.country]
test  _b[c.confios@1bn.groupnum#840.country] =  _b[c.confios@3.groupnum#840.country]



* Figure 5.9

use "elitesperceived_citizens_test5.6.dta"

svyset [pw=extS018] , strata(country)

tab elitecat, missing
recode elitecat .=88

svy: mean confios, over(groupnum elitecat) coeflegend
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#1bn.elitecat]
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#2.elitecat]
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#3.elitecat]
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#4.elitecat]
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#5.elitecat]
test  _b[c.confios@1bn.groupnum#88.elitecat] =  _b[c.confios@3.groupnum#6.elitecat]





